package spring.factory;

import org.springframework.beans.factory.config.SingletonBeanRegistry;
import spring.model.BeanDefinition;


public class DefaultBeanFactory {

    private BeanDefinitonRegistry DEFINITIONS = new BeanDefinitonRegistry();

    private final SingletonBeanRegistry SINGLETONS = new SingletonBeanRegister();

    public void registerBeanDefinition(BeanDefinition bd) {
        DEFINITIONS.registerBeanDefinition(bd);
    }

    private Object createBean(BeanDefinition bd) {

        try {
            Class clazz = Class.forName(bd.getClazz());

            return clazz.getConstructor().newInstance();
        } catch (Exception e) {
            throw new RuntimeException("");
        }
    }

    public Object getBean(String beanName) {

        return DEFINITIONS.getBeanDefinition(beanName);
    }
}
